package com.asl.website.serviceContent.domain;

/**
 * @author 482944566@qq.com
 * @version 1.0
 * @date 2025-05-22
 */

import com.asl.common.utils.StringUtils;
import com.asl.website.common.Language;

/**
 * 服务内容响应DTO
 */
public class SysServiceContentDTO {
    private Long contentId;
    private String title;
    private String content;
    private String itemIcon;
    private Integer typeId;
    private Integer sortOrder;
    private String language;

    public SysServiceContentDTO(SysServiceContent entity, String language) {
        this.contentId = entity.getContentId();
        this.itemIcon = entity.getItemIcon();
        this.sortOrder = entity.getSortOrder();
        this.typeId=entity.getTypeId();
        this.language = language;

        switch (Language.fromCode(language)) {
            case EN_US:
                this.title = StringUtils.firstNonBlank(entity.getContentTitleEn(), entity.getContentTitleZh());
                this.content = StringUtils.firstNonBlank(entity.getDetailContentEn(), entity.getDetailContentZh());
                break;
            case DE_DE:
                this.title = StringUtils.firstNonBlank(entity.getContentTitleDe(), entity.getContentTitleZh());
                this.content = StringUtils.firstNonBlank(entity.getDetailContentDe(), entity.getDetailContentZh());
                break;
            default: // 默认中文
                this.title = entity.getContentTitleZh();
                this.content = entity.getDetailContentZh();
        }
    }

    public Integer getTypeId() {
        return typeId;
    }

    // getters
    public Long getContentId() {
        return contentId;
    }

    public String getTitle() {
        return title;
    }

    public String getContent() {
        return content;
    }

    public String getItemIcon() {
        return itemIcon;
    }

    public Integer getSortOrder() {
        return sortOrder;
    }


    public String getLanguage() {
        return language;
    }
}